package com.jw.system.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jw.response.Result;
import com.jw.system.entity.Role;
import com.jw.system.entity.vo.DepartmentVO;
import com.jw.system.entity.vo.RoleVO;
import com.jw.system.service.MenuService;
import com.jw.system.service.RoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 岗位表 前端控制器
 * </p>
 *
 * @author jw
 * @since 2021-04-20
 */
@RestController
@RequestMapping("/role")
@Api(value = "系统角色模块", tags = "系统角色接口")
public class RoleController {

    @Autowired
    private RoleService roleService;

    /**
     * 获取部门列表
     * @return
     */
    @ApiOperation(value = "角色列表", notes = "模糊查询角色列表")
    @PostMapping("/getRoleList")
    public Result getRoleList(@RequestParam(value = "current", defaultValue = "1") Integer current,
                              @RequestParam(value = "size", defaultValue = "7") Integer size,
                              @RequestBody RoleVO roleVO) {
        Page<RoleVO> roleVOPage = roleService.getRoleList(current, size, roleVO);
        return Result.ok().data("role",roleVOPage.getRecords()).data("total",roleVOPage.getTotal());
    }

    @ApiOperation(value = "所有角色")
    @GetMapping("/findAll")
    public Result findAll() {
        List<Role> role = roleService.findAll();
        return Result.ok().data("roles",role);
    }

}

